#ifndef ENTITYPLAYER_H
#define ENTITYPLAYER_H

#include "WorldEntity.h"
#include "InputAction.h"
#include <vector>
using namespace std;

//!represent the entity player
class CEntityPlayer:public CWorldEntity
{
private:
	//!Speed of the player
	int m_speed;

	//!Store the inputs
	vector<eAction> m_vectorAction;

	//!Animation's index of the player walking to the right
	int m_idAnimWalkRight;

	//!Animation's index of the player walking to the left
	int m_idAnimWalkLeft;

	//!Animation's index of the player facing to the left
	int m_idAnimIdleLeft;

	//!Animation's index of the player facing to the right
	int m_idAnimIdleRight;

	//!Animation's index of the player jumping to the left
	int m_idAnimJumpLeft;

	//!Animation's index of the player jumping to the right
	int m_idAnimJumpRight;

	//!Animation's index of the player attacking to the left
	int m_idAnimAttackLeft;

	//!Animation's index of the player attacking to the right
	int m_idAnimAttackRight;

	//!Index of the current sprite displayed (for animation)
	int m_animIdOfSprite;

	//!Start display time of the current animation frame.
	int m_animTime;

	//!Represent the state of the player.
	enum eStatePlayer
	{
		eStateStill,
		eStateMove,
		eStateJumpUp,
		eStateJumpDown
	};

	//!Represent the direction facing by the player.
	enum eStateDirectionPlayer
	{
		eDirectionLeft,
		eDirectionRight
	};

	//!State of the player
	eStatePlayer m_statePlayerAction;

	//!Direction of the player.
	eStateDirectionPlayer m_statePlayerDirection;

	//!Jump time start.
	int m_timeStartJump;

	//!Jump duration time.
	int m_durationJump;

	//!Start time attack
	int m_timeStartAttack;

	//!Time between two attacks.
	int m_durationBetweenTwoAttack;

public:
	//!Constructor
	/*!
	\param startPosition Initial position of the player.
	\param speed Speed of the player.
	\param idAnimWalkRight Animation index of the player walking to the right.
	\param idAnimWalkLeft Animation index of the player walking to the left.
	\param indexAnimIdleRight Animation index of the player facing to the right.
	\param indexAnimIdleLeft Animation index of the player facing to the left.
	\param indexAnimJumpRight Animation index of the player jumping to the right.
	\param indexAnimJumpLeft Animation index of the player jumping to the left.
	\param indexAnimAttackRight Animation index of the player attacking to the right.
	\param indexAnimAttackLeft Animation index of the player attacking to the left.
	*/
	CEntityPlayer(const CVector2i& startPosition, int speed, int idAnimWalkRight,
		int idAnimWalkLeft, int indexAnimIdleRight, int indexAnimIdleLeft, int indexAnimJumpRight, int indexAnimJumpLeft,
		int indexAnimAttackRight, int indexAnimAttackLeft);

	//!Destructor
	~CEntityPlayer();

	//!Update the player.
	void doUpdate(void);

	//!Render the player.
	void doRender(void);

	//!Make the player perform an action.
	/*!
	\param newAction The action to perform.
	*/
	void addAction(eAction newAction);

private:
	//!The player move to the left
	void movePlayerLeft();

	//!The player move to the right
	void movePlayerRight();

	//!The up part of a jump
	void playerJumpUp();

	//!The down part of a kump
	void playerJumpDown();

	//!Make the player attack
	void attack();

	//!Reset the animation's data. Called when the animation changed.
	void resetAnimData(void);
	
};
#endif
